package org.kevin.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.kevin.domain.QueryRequest;
import org.kevin.domain.Role;
import org.kevin.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @ClassName: RoleController
 * @Description: TODO
 * @Author: kevin
 * @Date: 2019/8/26 7:14 下午
 * @Version: 1.0
 */
@Controller
public class RoleController extends BaseController{

    @Autowired
    RoleService roleService;

    @RequestMapping("bootstrap-table")
    public String roleIndex() {
        return "bootstrap-table";
    }

    @RequestMapping("bootstrap-table/list")
    @ResponseBody
    public Map<String, Object> roleList(QueryRequest request, Role role) {
        PageHelper.startPage(request.getPageNum(), request.getPageSize());
        List<Role> roles = this.roleService.getRoles(role);
        PageInfo<Role> pageInfo = new PageInfo<>(roles);
        return getDataTable(pageInfo);
    }
}
